/**************************************************************************/
/*  Copyright (C) School of Software Engineering of USTC, 2012            
/*                                                                        
/*  FILE NAME: util.h                                                    
/*  PRINCIPAL AUTHOR: SA12226114(Xin Zhu), SA12226139(Dan Shu)            
/*  SUBSYSTEM NAME:                                                     
/*  MODULE NAME: util                                                    
/*  LANGUAGE: C                                                           
/*  TARGET ENVIRONMENT: Linux                                             
/*  DATE OF FIRST RELEASE: 2012-11-20                                     
/*  DESCRIPTION: Impement of Abstract Interface for Tokyo Cabinet DB API  
/**************************************************************************/


#ifndef UTIL_H
#define UTIL_H


/*****************************************************************
Function Name: util_init
Description: init string buffer
Parameter:  
@mem: a pointer to memory need to be initialized
@size: size of memory 
******************************************************************/
void util_init(char *mem, int size);


/*****************************************************************
Function Name: util_menu
Description: display menu
Parameter:  void
Author: SA12226114(Xin Zhu), SA12226139(Dan Shu)
Date: 2012-11-27
******************************************************************/
void util_menu();


/*****************************************************************
Function Name: util_getcommandline
Description: get command line from console
Parameter:  
@cmdline: a pointer to a buffer perserves command line which is from console
@size: buffer size
******************************************************************/
void util_getcommandline(char *cmdline, int size);


/*****************************************************************
Function Name: util_parse
Description: parse command line
Parameter:  
@string: a pointer to a buffer perserves command line which is from console
@strlen: command line length
@argv0: a pointer to a buffer, which perserves command.
@argv1: a pointer to a buffer, which perserves key.
@argv2: a pointer to a buffer, which perserves value.
******************************************************************/
void util_parse(char *string, int strlen, char *argv0, char *argv1, char *argv2);


/*****************************************************************
Function Name: util_memset
Description: format buffer
Parameter:  
@str: a pointer to a buffer perserves command line which is from console
@length: string length
******************************************************************/
void util_memset(char *str, int length);


/*****************************************************************
Function Name: util_format
Description: format command line
Parameter:  

@cmdline: a pointer to a buffer perserves command line which is from console
@cmd: a pointer to a buffer, which perserves command.
@key: a pointer to a buffer, which perserves key.
@value: a pointer to a buffer, which perserves value.

Author: SA12226114(Xin Zhu), SA12226139(Dan Shu)
Date: 2012-11-27
******************************************************************/
void util_format(char *cmdline, char *cmd, char *key, char *value);



#endif
